<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8" />
	<meta http-equiv="expires" content="wed, 26 feb 1997 08:21:57 gmt"> 
	<title><!-- if $cate_rs -->{$cate_rs.title}管理器<!-- else -->附件管理器<!-- /if --></title>
	<meta name="author" content="phpok.com" />
	<style type="text/css">
	html{font-size:14px;font-family:"Microsoft Yahei","宋体","Arial","Tahoma";margin:0;padding:0;background:#FFFFFF;}
	body{margin:3px;padding:0;overflow-y:scroll;_margin:0; _height:100%;}
	a{color:#000;text-decoration: none;}
	ul.filelist{list-style:none;padding:0;margin:0}
	ul.filelist li{float:left;margin:3px 5px;height:75px;width:296px;padding:1px;border:1px solid #ccc;cursor:pointer;}
	ul.filelist li:hover{background:#efefef;}
	ul.filelist li .ico{float:left;width:75px;height:75px;text-align:center;position:relative;z-index: 2;}
	ul.filelist li .ico .checkbox{position:absolute;width:20px;height:20px;background:#fff;top:1px;left:1px;z-index:1;}
	ul.filelist li .note{float:left;width:220px;overflow:hidden;}
	ul.filelist li .note .info{line-height:22px;overflow:hidden;height:22px;}
	ul.filelist li img.img{width:73px;height:73px;text-align:center;padding:1px;}
	.pagelist{text-align:center;height:30px;overflow:hidden;margin-top:7px;}
	.pagelist ul{list-style:none;margin:0;padding:0;text-align:center;}
	.pagelist ul li{display:inline;height:22px;line-height:24px;margin:0 5px 0 0;}
	.pagelist ul li a{display:inline;padding:1px 5px;border:1px solid #ddd;cursor:pointer;}
	.pagelist ul li a:hover{background:#efefef;border:1px solid #ccc;text-decoration:none;}
	.pagelist ul li a.current{background:#E4E4E4;border:1px solid #ccc;text-decoration:none;}
	div.clear{clear:both;height:0;line-height:0;overflow:hidden;display:block;visibility:hidden;}
	.search{border:1px solid #E5E5E5;background:#F5F5F5;padding-left:12px;line-height:25px;margin-top:3px;}
	select{padding:3px;}
	input.keywords{width:150px;padding:3px;border:1px solid #ABADB3;}
	</style>
	<link rel="stylesheet" type="text/css" href="{#css#}/open.css" />
	<link rel="stylesheet" type="text/css" href="{#css#}/artdialog.css" />
	<link rel="stylesheet" type="text/css" href="{#css#}/form.css" />
	{func phpok_head_css}
	<script type="text/javascript" src="{url ctrl=js ext=jquery.artdialog.js /}"></script>
	{func phpok_head_js}
	<!-- plugin head -->
	<script type="text/javascript">
	function check_search()
	{
		if(!$("#keywords").val()){
			$.dialog.alert('请输入要搜索的关键字');
			return false;
		}
		return true;
	}
	function delete_it(t){
		var obj = $.dialog.opener;
		var id = $(t).attr('data');
		var old = obj.$("#{$id}").val();
		if(!old || old == 'undefined' || old == id){
			$("#select_filelist").html('').hide();
			$(".filelist li").show();
			obj.$("#{$id}").val('');
			obj.obj_{$id}.showhtml();
			return true;
		}
		var lst = old.split(",");
		var ids = new Array();
		var m = 0;
		for(var i in lst){
			if(lst[i] != id){
				ids[m] = lst[i];
				m++;
			}
		}
		$("#li_"+id).show();
		showhtml(ids.join(","));
	}
	function showhtml(id)
	{
		if(!id || id == 'undefined'){
			id = obj.$("#{$id}").val();
		}
		if(!id || id == 'undefined'){
			$("#select_filelist").html('').hide();
			return false;
		}
		var obj = $.dialog.opener;
		var url = get_url('upload','thumbshow','id='+$.str.encode(id));
		$.phpok.json(url,function(rs){
			if(rs.status == 'ok'){
				var html = '<ul class="piclist">';
				var ids = '';
				for(var i in rs.content){
					html += '<li id="selected_'+rs.content[i].id+'" data="'+rs.content[i].id+'" onclick="delete_it(this)">';
					html += '<div class="pic"><img src="'+rs.content[i].ico+'" width="80" border="0" /></div>';
					html += '</li>';
					if(ids){
						ids += ",";
					}
					ids += (rs.content[i].id).toString();
					$("#li_"+rs.content[i].id).hide();
				}
				html += '</ul><div class="clear"></div>';
				$("#select_filelist").html(html).show();
				if(ids){
					obj.$("#{$id}").val(id);
					obj.obj_{$id}.showhtml();
				}
				return true;
			}
			if(rs.status != 'ok'){
				$.dialog.alert(rs.content);
				return false;
			}
		});
	}
	$(document).ready(function(){
		$(".filelist li").click(function(){
			var obj = $.dialog.opener;
			var id = $(this).attr('data');
			var multiple = '{$multiple}';
			if(multiple){
				var old = obj.$("#{$id}").val();
				if(old && old != 'undefined'){
					var new_val = old+","+id;
				}else{
					var new_val = id;
				}
				$(this).hide();
				showhtml(new_val);
			}else{
				obj.$("#{$id}").val(id);
				obj.obj_{$id}.showhtml();
				$.dialog.close();
			}
		});
	});
	</script>
</head>
<body>
<div class="search">
	<form method="post" action="{$formurl}" onsubmit="return check_search()">
	<table>
	<tr>
		<td>搜索：</td>
		<td><input type="text" name="keywords" id="keywords" value="{$keywords}" class="keywords" /></td>
		<td><input type="submit" value=" {lang搜索} " /></td>
		<td><input type="button" value=" {lang取消搜索} " onclick="$.phpok.go('{$formurl}')" /></td>
		<td><input type="button" value=" {lang刷新} " onclick="$.phpok.reload()" /></td>
	</tr>
	</table>
	</form>
</div>
<div id="select_filelist"></div>
<ul class="filelist">
	<!-- loop from=$rslist key=$key value=$value id=$tmpid -->
	<li id="li_{$value.id}" data="{$value.id}">
		<div class="li_bg">
		<div class="ico">
			<img src="{$value.ico}" class="img" />
		</div>
		<div class="note">
			<div class="info">名称：{$value.title}</div>
			<div class="info">添加：{func date "Y-m-d H:i" $value.addtime}</div>
			<div class="info">属性：{$value.attr ? $value.attr.width.' x '.$value.attr.height : '-'}</div>
		</div>
		<div class="clear"></div>
		</div>
	</li>
	<!-- /loop -->
	<div class="clear"></div>
</ul>
<!-- if $pagelist -->
<div class="pagelist">
<ul>
	<!-- loop from=$pagelist key=$key value=$value id=$tmpid -->
	<li><a href="{$value.url}"{if $value.status} class="current"{/if}>{$value.title}</a></li>
	<!-- /loop -->
</ul>
</div>
<!-- /if -->

<script type="text/javascript">
$(document).ready(function(){
	var obj = $.dialog.opener;
	var old = obj.$("#{$id}").val();
	if(old){
		showhtml(old);
	}
});
</script>
</body>
</html>